﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using timetableasy.Models;

namespace timetableasy.Controllers
{
    public class CampusManagerUserController : UsersController
    {
        static CampusManagerUserRepository campusManagerUserRepository = new CampusManagerUserRepository();
        //
        // GET: /CampusManagerUser/

        public ActionResult Index()
        {
            var campusManagerUsers = campusManagerUserRepository.FindAllCampusManagerUsers().ToList();
            return View("Index", campusManagerUsers);
        }

        //
        // GET: /CampusManagerUser/Details/5

        public ActionResult Details(int id)
        {
            CampusManagerUser cmu = campusManagerUserRepository.GetCampusManagerUserById(id);
            if (cmu == null)
                return View("NotFound");
            else
                return View("Details", cmu);
        }

        //
        // GET: /CampusManagerUser/Create

        //public ActionResult Create()
        //{
        //    return View();
        //} 

        //
        // POST: /CampusManagerUser/Create

        //[HttpPost]
        //public ActionResult Create(FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add insert logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        //
        // GET: /CampusManagerUser/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /CampusManagerUser/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //public override ModelStateDictionary CreateUser(User u, ModelStateDictionary m)
        //{
        //    CampusManagerUser cmu = new CampusManagerUser(u);
        //    try
        //    {
        //        campusManagerUserRepository.Add(cmu);
        //        campusManagerUserRepository.Save();
        //    }
        //    catch
        //    {
        //        foreach (var issue in u.GetRuleViolations())
        //        {
        //            m.AddModelError(issue.PropertyName, issue.ErrorMessage);
        //        }
        //    }
        //    return m;
        //}
    }
}
